//
//  ZZFResourcesCache.m
//  ZZFBundleKit
//
//  Created by quheng on 2017/9/20.
//  Copyright © 2017年 quheng. All rights reserved.
//

#import "BZResourcesCache.h"

static BZResourcesCache *resourceCache = nil;

@interface BZResourcesCache()

@property (nonatomic, strong) NSCache *cache;

@end

@implementation BZResourcesCache


+ (instancetype)shareInstance{

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{

        resourceCache = [[BZResourcesCache alloc]init];
    });
    
    return resourceCache;
}

- (NSCache *)cache{

    if (!_cache) {
        
        _cache = [[NSCache alloc]init];
        [_cache setCountLimit:1024*1024];//设置单个文件最大值
        [_cache setTotalCostLimit:1000];//设置缓存总数
        
    }
    return _cache;
}


- (NSCache *)getResourcesCache{

    return self.cache;

}


- (void)setMaxCache:(NSUInteger)max{

    [self.cache setTotalCostLimit:max];
}


- (void)removeAllCache{

    [self.cache removeAllObjects];

}

- (void)removeCacheInRange:(NSRange)renge{

//    [self.cache re]

}

@end
